package com.louis.aoplogin.aspect;

import android.util.Log;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;

@Aspect
public class ClickBehaviorAspect {

    private static final String TAG = "ClickBehaviorAspect";

    @Pointcut("execution(@com.louis.aoplogin.annotation.ClickBehavior * *(..))")
    public void methodPointCut(){}

    @Around("methodPointCut()")
    public Object jointPoint(ProceedingJoinPoint joinPoint) throws Throwable {
        Log.i(TAG, "jointPoint: ");
        Object result = joinPoint.proceed();
        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
        String[] parameterNames = signature.getParameterNames();

        for (String parameterName : parameterNames) {
            Log.i(TAG, "jointPoint: " + parameterName);
        }
        return result;
    }
}
